package com.nageoffer.jobtrain.common.framework.config;

import com.nageoffer.jobtrain.common.framework.idempotent.NoMQDuplicateConsumeAspect;
import com.nageoffer.jobtrain.common.framework.idempotent.NoSmsFrequentRequestAspect;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * 幂等性相关配置类
 * author：唐晨
 */
public class IdempotentConfiguration {
    /**
     * 防止消息重复消费幂等性切面控制器
     */
    @Bean
    public NoMQDuplicateConsumeAspect noMQDuplicateConsumeAspect(StringRedisTemplate stringRedisTemplate) {
        return new NoMQDuplicateConsumeAspect(stringRedisTemplate);
    }

    /**
     * 防止用户一分钟内重复申请验证码请求切面控制器
     */
    @Bean
    public NoSmsFrequentRequestAspect noSmsFrequentRequestAspect(StringRedisTemplate stringRedisTemplate) {
        return new NoSmsFrequentRequestAspect(stringRedisTemplate);
    }
}
